package xue;

import org.junit.Test;

import java.lang.reflect.Field;

public class Student {
    private String name;
    private int age;


    private  void find(String name, int age){
        System.out.println(name+"："+age);
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}

class One{

    public static void main(String[] args) {
        try {
            t();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void t() throws Exception{
        Class c=Student.class;
        try {
            Object obj=c.newInstance();
            Field f=c.getDeclaredField("name");
            System.out.println(f.getName());
            f.setAccessible(true);
            f.set(obj,"aaaaa");

            System.out.println(f.get(obj));
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        }
    }
}
